<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('审核岗位信息')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-post-edit" th:object="${wstPost}">
        <input name="postId" th:field="*{postId}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label">岗位编码：</label>
            <div class="col-sm-8">
                <input name="postCode" th:field="*{postCode}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">岗位名称：</label>
            <div class="col-sm-8">
                <input name="postName" th:field="*{postName}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">招聘人数：</label>
            <div class="col-sm-8">
                <input name="needNum" th:field="*{needNum}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">工资：</label>
            <div class="col-sm-8">
                <input name="salary" th:field="*{salary}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">工作介绍：</label>
            <div class="col-sm-8">
                <textarea name="mainwork" th:field="*{mainwork}" class="form-control" type="text" rows="5"></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">工作地址：</label>
            <div class="col-sm-8">
                <input name="workplace" th:field="*{workplace}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">招聘开始时间：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <input name="startTime" th:value="${#dates.format(wstPost.startTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">招聘结束时间：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <input name="endTime" th:value="${#dates.format(wstPost.endTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">联系电话：</label>
            <div class="col-sm-8">
                <input name="phone" th:field="*{phone}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <textarea name="remark" class="form-control">[[*{remark}]]</textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">意见：</label>
            <div class="col-sm-8">
                <textarea name="content" class="form-control" required></textarea>
            </div>
        </div>
        <div class="form-group" hidden>
            <label class="col-sm-3 control-label">接受用户ID：</label>
            <div class="col-sm-8">
                <input name="userId" th:value="*{createUserId}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group" hidden>
            <label class="col-sm-3 control-label">记录类型：</label>
            <div class="col-sm-8">
                <input name="type" th:value="examine_post" class="form-control" type="text">
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<th:block th:include="include :: bootstrap-fileinput-js"/>
<script th:inline="javascript">
    var prefix = ctx + "wstudy/post";
    var prefixProcess = ctx + "wstudy/process";

    $("#form-post-edit").validate({
        focusCleanup: true
    });

    function submitHandlerAgree() {
        let params2 = {
            "receiveUserId":[[${wstPost.createUserId}]],
            "status":"no",
            "content":"消息内容：同意发布此岗位！",
            "type":"审批消息"
        }
        if ($.validate.form()) {
            $.operate.save(prefixProcess + "/examinePost", $('#form-post-edit').serialize()+"&status="+"AGREE",function () {
                $.operate.post( "/wstudy/message/send",params2)
            });
        }
    }
    function submitHandlerDisAgree() {
        let params2 = {
            "receiveUserId":[[${wstPost.createUserId}]],
            "status":"no",
            "content":"消息内容：不同意发布此岗位！",
            "type":"审批消息"
        }
        if ($.validate.form()) {
            $.operate.save(prefixProcess + "/examinePost", $('#form-post-edit').serialize()+"&status="+"DISAGREE",function () {
                $.operate.post( "/wstudy/message/send",params2)
            });
        }
    }
    $("input[name='startTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='endTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $(".file-upload").each(function (i) {
        var val = $("input[name='" + this.id + "']").val()
        $(this).fileinput({
            'uploadUrl': ctx + 'common/upload',
            initialPreviewAsData: true,
            initialPreview: [val],
            maxFileCount: 1,
            autoReplace: true
        }).on('fileuploaded', function (event, data, previewId, index) {
            $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })
        $(this).fileinput('_initFileActions');
    });
</script>
</body>
</html>